import pyWinhook as pyHook
import pythoncom

def OnKeyboardEvent(event):
    global keyDatabase
    # global keyLoggerCount
    # keyLoggerCount += 1

    # http://code.activestate.com/recipes/553270-using-pyhook-to-block-windows-keys/
    print ('MessageName:',event.MessageName )
    print ('Message:',event.Message)
    print ('Time:',event.Time)
    print ('Window:',event.Window)
    print ('WindowName:',event.WindowName)
    print ('Ascii:', event.Ascii, chr(event.Ascii) )
    print ('Key:', event.Key)
    print ('KeyID:', event.KeyID)
    print ('ScanCode:', event.ScanCode)
    print ('Extended:', event.Extended)
    print ('Injected:', event.Injected)
    print ('Alt', event.Alt)
    print ('Transition', event.Transition)
    print ('---')

    # check to see if this key has ever been pressed before
    # if it has not then add it and set its start value to zero.
    if event.Key not in keyDatabase:
        keyDatabase[ event.Key ] = 0

    # Incurment the key value
    keyDatabase[ event.Key ] += 1
    return True

# When the user presses a key down anywhere on their system
# the hook manager will call OnKeyboardEvent function.
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()

while True :
    pythoncom.PumpWaitingMessages()